/*
 * Licensed under the License, Version 1.0 (the "License");
 * You may obtain a copy of the License at
 *   http://www.heavenick.com/license/License 
 * Copyright information Heavenick to all.
 * Unless the applicable legal requirements or written 
 * consent, can use or around the code, and no warranties 
 * of any kind and state responsibility.
 */
package com.heavenick.core.monitor;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.aspectj.lang.ProceedingJoinPoint;
/**
*
*@author Heavenick
*@version 1.0
*@date 2012-9-17 上午09:17:03
*/
public class ExcuteTimeMonitor implements MethodInterceptor{

	public Object invoke(ProceedingJoinPoint joinPoint) throws Throwable {
		Long startTime = System.currentTimeMillis();
		Object obj = joinPoint.proceed();
		Long endTime = System.currentTimeMillis();
		System.err.println("excute the method ["+joinPoint.getTarget()+ "],and take time is " + (endTime-startTime));
		return obj;
	}

	public Object invoke(MethodInvocation arg0) throws Throwable {
		Long startTime = System.currentTimeMillis();
		Object obj = arg0.proceed();
		Long endTime = System.currentTimeMillis();
		System.out.println("excute the method ["+arg0.getMethod()+ "],and take time is " + (endTime-startTime));
		return obj;
	}

}
